﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProcessFile
{
    class ConvertStk4StackupFile
    {

        public string Id = Common.RandomId;
        public string SubId = Common.RandomId;
        public int StartIdMechanical = AD14LayerId.LAYER_V8_Mechanical1;
        public int Id0 { set; get; }
        public int Id1 { set; get; }
        public  string Hearder
        {
            get
            {
                string hearder =
                    string.Format(
                        @"STACKUPVERSION=1
LAYERMASTERSTACK_V8ID={0}
LAYERMASTERSTACK_V8NAME=Master layer stack
LAYERMASTERSTACK_V8ISFLEX=False
LAYERMASTERSTACK_V8SHOWTOPDIELECTRIC=True
LAYERMASTERSTACK_V8SHOWBOTTOMDIELECTRIC=True
LAYERMASTERSTACK_V8STYLE=1
DISPLAYUNIT=1
LAYERMASTERSTACK_V8ID={0}
LAYERSUBSTACK_V8_0ID={1}
LAYERSUBSTACK_V8_0NAME=Board Layer Stack
LAYERSUBSTACK_V8_0ISFLEX=False
LAYERSUBSTACK_V8_0SHOWTOPDIELECTRIC=True
LAYERSUBSTACK_V8_0SHOWBOTTOMDIELECTRIC=True
LAYERSUBSTACK_V8_0TYPE=1
LAYERSUBSTACK_V8_0USEDBYPRIMS=TRUE
LAYERSUBSTACK_V8_0SERVICE=FALSE
LAYER_V8_0LAYERID={4}
LAYER_V8_0ID={2}
LAYER_V8_0NAME=Top Paste
LAYER_V8_0USEDBYPRIMS=FALSE
LAYER_V8_0_{1}CONTEXT=0
LAYER_V8_0_{1}USEDBYPRIMS=FALSE
LAYER_V8_1LAYERID={5}
LAYER_V8_1ID={3}
LAYER_V8_1NAME=Top Overlay
LAYER_V8_1USEDBYPRIMS=FALSE
LAYER_V8_1_{1}CONTEXT=0
LAYER_V8_1_{1}USEDBYPRIMS=FALSE
", Id, SubId, Common.RandomId, Common.RandomId, AD14LayerId.LAYER_V8_Top_Paste, AD14LayerId.LAYER_V8_Top_Overlay);
                return hearder;
            }
        }
        public  string Footer(int indexStar,int seqStart)
        {
            string bottom =
                string.Format(
                    @"LAYER_V8_{0}LAYERID={1}
LAYER_V8_{0}ID={2}
LAYER_V8_{0}NAME=Bottom Overlay
LAYER_V8_{0}USEDBYPRIMS=FALSE
LAYER_V8_{0}_{3}CONTEXT=0
LAYER_V8_{0}_{3}USEDBYPRIMS=FALSE
",
                    indexStar, AD14LayerId.LAYER_V8_Bottom_Overlay, Common.RandomId, SubId);
            bottom += string.Format(
                @"LAYER_V8_{0}LAYERID={1}
LAYER_V8_{0}ID={2}
LAYER_V8_{0}NAME=Bottom Paste
LAYER_V8_{0}USEDBYPRIMS=FALSE
LAYER_V8_{0}_{3}CONTEXT=0
LAYER_V8_{0}_{3}USEDBYPRIMS=FALSE
",
                indexStar+1, AD14LayerId.LAYER_V8_Bottom_Paste, Common.RandomId, SubId);
            indexStar = indexStar + 1;
            seqStart = seqStart + 1;
            for (int i = 1; i <= 32; i++)
            {
                bottom +=
                    string.Format(
                        @"LAYER_V8_{0}LAYERID={1}
LAYER_V8_{0}ID={2}
LAYER_V8_{0}NAME=Mechanical {3}
LAYER_V8_{0}USEDBYPRIMS=FALSE
LAYER_V8_{0}_{4}CONTEXT=0
LAYER_V8_{0}_{4}USEDBYPRIMS=FALSE
LAYER_V8_{0}MECHENABLED=False
",
                        indexStar + i, StartIdMechanical+ (i-1), Common.RandomId, i, SubId);
            }
            return bottom;
        }
    }
}
